struct Val {
    val: f64,
}

struct GenVal<T> {
    gen_val: T,
}

impl Val {
    fn value(&self) -> &f64 {
        &self.val
    }
}

impl<T> GenVal<T> {
    fn value(&self) -> &T {
        &self.gen_val
    }
}

fn main() {
    println!("泛型方法");

    let v = Val { val: 3.0 };
    let g = GenVal { gen_val: 3_i64 };

    println!("{},{}", v.value(), g.value());
    let g = GenVal {
        gen_val: "str_type".to_string(),
    };
    println!("{},{}", v.value(), g.value());
}
